//
//  IMAlertKeyWordRequest.m
//  BaseProject
//
//  Created by 王洋 on 2021/4/14.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "IMAlertKeyWordRequest.h"

@implementation IMAlertKeyWordRequest

+ (void)request_imKeyWordComption:(void (^)(BOOL success))comption {
    
    NSMutableDictionary *dic = @{}.mutableCopy;
//    [dic setValue:@"1" forKey:@"isDisabled"];
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,@"/indexApp/getTalkKeyWord"];
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        if ([data isKindOfClass:[NSDictionary class]]) {
            //请求成功
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) {

                NSArray *resultArray = [data valueForKey:@"data"];
                NSMutableArray *keys = @[].mutableCopy;
                if ([resultArray isKindOfClass:[NSArray class]]) {
                    for (NSDictionary *dic in resultArray) {
                        [keys addObject:[dic valueForKey:@"keyWord"]];
                    }
                    [[NSUserDefaults standardUserDefaults] setValue:keys forKey:@"user_imKeyWordArray"];
                    [[NSUserDefaults standardUserDefaults] synchronize];
                    
                    comption(YES);
                }
            } else {

            }
        }
    } FailedBlock:^(NSError * _Nonnull error) {
        comption(NO);
    }];
    
}

@end
